﻿using System;
using System.Collections;
using System.Configuration;
using System.Globalization;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class WebUserControl_Khoasongay : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = BCDataCenter.Configuration.CurrentConnectionString;
    static string error = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDrop();
            DropTTPP.SelectedValue = Session["sitecode"].ToString();
           
        }
        dt = new ClassExecute.ClassExecute();
        txtLastClosedDate.Text = dt.GetDataDepend(str, "[ls_getClosedDate]", CommandType.StoredProcedure, ref error,
          new SqlParameter("@siteCode", Session["sitecode"].ToString()));

    }
    void BindDrop()
    {
        dt = new ClassExecute.ClassExecute();
        DataTable db = dt.Get_Data_DataTable(str, ref error, "[ls_getDistributorList]", CommandType.StoredProcedure);
        DropTTPP.DataSource = db;
        DropTTPP.DataTextField = "sitename";
        DropTTPP.DataValueField = "Sitecode";
        DropTTPP.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            dt = new ClassExecute.ClassExecute();
            string kq = dt.GetDataDepend(str, "ls_closeWorkingDay", CommandType.StoredProcedure, ref error,
                new SqlParameter("@mSiteCode", Session["sitecode"].ToString()));
            uscMsgBox1.AddMessage(kq, uscMsgBox.enmMessageType.Success);
        }
        catch(Exception ex)
        {
            BCDataCenter.ClassWriteLogErr obj = new BCDataCenter.ClassWriteLogErr();
            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            obj.ErrorLog(ex.Message, method);
        }
    }

   
}
